#pragma region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#pragma endregion

#pragma once

class Module : public CAtlDllModuleT<Module>
{
private:
	typedef HRESULT STDAPICALLTYPE DllGetClassObjectProc(REFCLSID rclsid, REFIID riid, LPVOID* ppv);

	HMODULE _dxLibrary;
	DllGetClassObjectProc* _dllGetClassObject;

	HRESULT RegisterClass(REFCLSID rclsid, const wchar_t* modulePath);
	HRESULT UnregisterClass(REFCLSID rclsid);

	HRESULT LoadDXLibrary();
	HRESULT FreeDXLibrary();
	HRESULT GetDXLibraryPath(CString& dxLibraryPath);

public:

	Module();
	~Module();

	HRESULT DllRegisterServer(BOOL bRegTypeLib = TRUE);
	HRESULT DllUnregisterServer(BOOL bUnRegTypeLib = TRUE);
	HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
};

__declspec(selectany) Module _Module;

